iconhelper: Fix drawing of empty and paintable helpers
authorBenjamin Otte <otte@redhat.com>
Wed, 5 Sep 2018 04:33:12 +0000 (06:33 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 5 Sep 2018 04:34:32 +0000 (06:34 +0200)
Empty helpers did try to draw a NULL paintable (not good) and in the
non-null case code used the wrong width/height.

gtk/gtkiconhelper.c

index 1c696a0d47006c68f75cabc78e8236961ce677fb..6b8f63e9ff67fd439d85dc734d5faf6f4cc1aa19 100644 (file)
@@ -242,9 +242,13 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
     default:
       {
         double image_ratio = (double) width / height;
-        double ratio = gdk_paintable_get_intrinsic_aspect_ratio (self->paintable);
+        double ratio;
         double x, y, w, h;
 
+        if (self->paintable == NULL)
+          break;
+
+        ratio = gdk_paintable_get_intrinsic_aspect_ratio (self->paintable);
         if (ratio == 0)
           {
             w = width;
@@ -268,7 +272,7 @@ gtk_icon_helper_paintable_snapshot (GdkPaintable *paintable,
         gtk_css_style_snapshot_icon_paintable (style,
                                                snapshot,
                                                self->paintable,
-                                               width, height,
+                                               w, h,
                                                self->texture_is_symbolic);
         gtk_snapshot_offset (snapshot, -x, -y);
       }